package com.example.common;

import org.apache.ibatis.exceptions.TooManyResultsException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;



@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = MethodArgumentNotValidException.class)
    public R handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
        return R.error("异常失败");
    }

    // 其他异常处理方法 TooManyResultsException
    @ExceptionHandler(value = TooManyResultsException.class)
    public R erro(TooManyResultsException e) {

        return R.error("账号异常！登录查到多条类似数据！");
    }
}

